package sceneGraph;

import javax.vecmath.*;

public class ObjectTriangle {
	private Point3f p0, p1, p2;
	private Vector3f N1, N2, N0;

	public ObjectTriangle(Point3f p0, Point3f p1, Point3f p2) {
		this.p0 = p0;
		this.p1 = p1;
		this.p2 = p2;

		Vector3f p2p0 = new Vector3f();
		Vector3f p0p1 = new Vector3f();
		Vector3f p1p2 = new Vector3f();
		p2p0.sub(p0, p2);
		p0p1.sub(p1, p0);
		p1p2.sub(p2, p1);

		N0 = new Vector3f();
		N0.cross(p2p0, p0p1);
		N1 = new Vector3f();
		N1.cross(p0p1, p1p2);
		N2 = new Vector3f();
		N2.cross(p1p2, p2p0);
	}

	public Point3f getVertex1() {
		return p0;
	}

	public Point3f getVertex2() {
		return p1;
	}

	public Point3f getVertex3() {
		return p2;
	}

	public Vector3f getNormal1() {
		return N0;
	}

	public Vector3f getNormal2() {
		return N1;
	}

	public Vector3f getNormal3() {
		return N2;
	}
}
